//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo40AND60;

public class demo_43 {
    public demo_43() {
    }

    public static void main(String[] args) {
        System.out.println(multiply("999999", "78888888"));
    }

    public static String multiply(String num1, String num2) {
        if (!num1.equals("0") && !num2.equals("0")) {
            int[] res = new int[num1.length() + num2.length()];

            for(int i = num1.length() - 1; i > 0; --i) {
                int n1 = num1.charAt(i) - 48;

                for(int j = num2.length() - 1; j > 0; --j) {
                    int n2 = num2.charAt(j) - 48;
                    int sum = n1 * n2 + res[i + j + 1];
                    res[i + j + 1] = sum % 10;
                    res[i + j] += sum / 10;
                }
            }

            StringBuilder sb = new StringBuilder();

            for(int i = 0; i < res.length; ++i) {
                if (res[i] != 0 && i != 0) {
                    sb.append(res[i]);
                }
            }

            return sb.toString();
        } else {
            return "0";
        }
    }
}
